package com.itheima.health.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.Role;
import com.itheima.health.service.RoleService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ：xu
 * @date ：Created in 2019/7/5
 * @description ：角色控制器
 * @version: 1.0
 */

@RestController
@RequestMapping("/role")
public class RoleController {

    @Reference
    private RoleService roleService;

    @RequestMapping("/findAll")
    public Result findAll(){
        try {
            //查询所有角色信息
            List<Role> roleList = roleService.findAll();
            //返回成功信息
            return new Result(true, MessageConst.ACTION_SUCCESS,roleList);
        } catch (Exception e) {
            e.printStackTrace();
            //返回失败信息
            return new Result(false,MessageConst.ACTION_FAIL);
        }
    }
}
